function [auc,dt]=AUC4N(dt,ns)

%AUC_OF_N Study of effect of sample size on AUC
%Syntax: [auc,dt]=AUC4N(dt,ns)
%Description: dt is a data structure of the type created by create_dt. 
%and ns is the sample size to be collected randomly. AUC is the area under
%the ROC curve 
%
%Jonas 2007 May 22

dt0=dt; %to keep the original for future use
n=size(dt.nx,1); %total number of samples
%Randomize sample order
[lala,Ind]=sort(rand(n,1));
Ind_test=Ind(ns+1:end);
%Train
Ind=Ind(1:ns);
dt.x=dt.x(Ind,:);
dt.nx=dt.nx(Ind,:);
dt.y=dt.y(Ind);
dt.dead=dt.dead(Ind);
dt.samples=dt.samples(Ind);
dt.data=dt.data(Ind,:);
dt=var_select_neighbor_val(dt); %training
%Test
dt_test=dt0;
dt_test.x=dt_test.x(Ind_test,:);
dt_test.nx=dt_test.nx(Ind_test,:);
dt_test.y=dt_test.y(Ind_test);
dt_test.dead=dt_test.dead(Ind_test);
dt_test.samples=dt_test.samples(Ind_test);
dt_test.data=dt_test.data(Ind_test,:);
%AUC
auc=cvroc([dt.y;dt_test.y],[neighbor_predict_within(dt);neighbor_predict(dt,dt_test.nx)],0);
%auc_cv=cvroc(dt.y,neighbor_predict_within(dt),0);
%auc_test=cvroc(dt_test.y,neighbor_predict(dt,dt_test.nx),0);

%disp(':-)')
